package com.youlu.campus.web.ads.controller;

import com.youlu.campus.service.ad.UserTaskAdsRecordService;
import com.youlu.campus.web.common.base.RequestContext;
import com.yuelin.infrastructure.quantum.common.QResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户任务广告控制器
 */
@RestController
public class UserTaskAdController {
    @Autowired
    private UserTaskAdsRecordService userTaskAdsRecordService;

    @PostMapping("/mini-app/user-task/ads/start")
    public QResult startViewAd(@RequestParam("adId") String adId, @RequestParam("taskId") String taskId) {
        return QResult.success(userTaskAdsRecordService.startViewAd(RequestContext.getUserId(), adId, RequestContext.getCurPlatform(), RequestContext.getAppId(), taskId));
    }

    @PostMapping("/mini-app/user-task/ads/end")
    public QResult endviewAd(@RequestParam("id") String id) {
        return QResult.success(userTaskAdsRecordService.endViewAd(RequestContext.getCurUser(), id));
    }
}
